// import './index.scss'
import { Card, Form, Input, Button, message } from "antd";

import { useDispatch } from "react-redux";
import { fetchLogin } from "../../store/modules/user";
import { useNavigate } from "react-router-dom";

const  Login = () => {
  const dispatch = useDispatch();
  const navigate=useNavigate()
  const  onFinish =async (value) => {
    console.log(value);
    await dispatch(fetchLogin(value));
    navigate('/')
    message.success('登录陈工')
  };

  return (
    <div>
      <Card>
        <Form onFinish={onFinish} validateTrigger="onBlur">
          <Form.Item
            label="Username"
            name="mobile"
            rules={[{ required: true, message: "Please input your username!" }]}
          >
            <Input placeholder="请输入手机"></Input>
          </Form.Item>

          <Form.Item
            label="password"
            name="code"
            rules={[{ required: true, message: "Please input your passowrd!" }]}
          >
            <Input placeholder="请输入验证码"></Input>
          </Form.Item>
          <Form.Item label={null}>
            <Button type="primary" htmlType="submit">
              Submit
            </Button>
          </Form.Item>
        </Form>
      </Card>
    </div>
  );
};

export default Login;
